ThisBuild / scalaVersion := "2.12.8"
ThisBuild / organization := "com.xrui"

val scalaTest = "org.scalatest" %% "scalatest" % "3.0.5"
val gigahorse = "com.eed3si9n" %% "gigahorse-okhttp" % "0.3.1"
val playJson  = "com.typesafe.play" %% "play-json" % "2.6.9"

val kafkaMgrApi  = "org.apache.kafka" %% "kafka" % "2.0.1"
// https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients
val kafkaClientApi  = "org.apache.kafka" % "kafka-clients" % "2.0.1"


val logslf4jlog4j = "org.slf4j" % "slf4j-log4j12" % "1.7.6"

val zookeeper     = "org.apache.zookeeper" % "zookeeper" % "3.4.6"

// scala
lazy val scalaj_http = "org.scalaj" %% "scalaj-http" % "1.0.1"
lazy val scala_arm = "com.jsuereth" %% "scala-arm" % "1.4"
lazy val scala_reflect = "org.scala-lang" % "scala-reflect" % "2.12.8"
lazy val scala_xml = "org.scala-lang.modules" %% "scala-xml" % "1.0.6"
lazy val reflections = "org.reflections" % "reflections" % "0.9.9-RC1"
lazy val typesafe_config = "com.typesafe" % "config" % "1.3.1"
lazy val scala_logging_slf4j = "com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2"
lazy val scala_logging = "com.typesafe.scala-logging" %% "scala-logging" % "3.5.0"


lazy val slf4j_api = "org.slf4j" % "slf4j-api" % "1.7.18"
lazy val slf4j_simple = "org.slf4j" % "slf4j-simple" % "1.7.18"

// avro
val avro_version = "1.7.6-cdh5.5.2"
lazy val avro = "org.apache.avro" % "avro" % avro_version

lazy val common_resolvers = Seq(
  // add link ~/.m2/repository to actual maven repo
  // if not use default repo location
  "central" at "http://central.maven.org/maven2/",
  "maven-hadoop" at "https://repository.cloudera.com/content/repositories/releases/",
  "cloudera" at "https://repository.cloudera.com/artifactory/cloudera-repos/",
  "Spray Micro-Repository" at "http://repo.spray.io/",
  Resolver.mavenLocal
)
resolvers ++= common_resolvers

lazy val scalaparent = (project in file("."))
  .aggregate(Core)
  .aggregate(leetCode)
  .aggregate(scalavro_util)
  .aggregate(scalavro_core)
  .aggregate(kafkaUtil)
  .dependsOn(Core)
  .settings(
    name := "scalaparent",
    libraryDependencies += scalaTest % Test,
  )

lazy val Core = (project in file("core"))
  .settings(
    name := "Core",
    libraryDependencies ++= Seq(gigahorse, playJson),
    libraryDependencies += scalaTest % Test,
  )

lazy val leetCode = (project in file("leetCode"))
  .settings(
    name := "lee Code",
    libraryDependencies += scalaTest % Test,
  )

lazy val scalavro_util = (project in file("scalavro/util"))
    .settings(
      name := "scalavro-util",
      libraryDependencies ++= Seq(
        scala_reflect,
        reflections,
        typesafe_config,
        scala_logging,
        slf4j_api,
        slf4j_simple % Test
      )
    )
lazy val spray_json = "io.spray" %% "spray-json" % "1.3.3"
lazy val jayway = "com.jayway.jsonpath" % "json-path" % "2.2.0"
lazy val diffson = "org.gnieh" %% "diffson" % "1.0.0"

lazy val scalavro_core = (project in file("scalavro/core"))
  .dependsOn (scalavro_util)
  .settings(
    name := "scalavro-core",
    libraryDependencies ++= Seq(
      avro,
      scala_xml,
      spray_json,
      jayway % Test,

    )
  )

lazy val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.5.8"
// https://mvnrepository.com/artifact/com.google.code.gson/gson
lazy val gson = "com.google.code.gson" % "gson" % "2.8.5"
lazy val fastjson = "com.alibaba" % "fastjson" % "1.2.58"
// https://mvnrepository.com/artifact/javax.mail/javax.mail-api
lazy val jmail = "javax.mail" % "javax.mail-api" % "1.6.2"

lazy val kafkaUtil = (project in file("kafkaUtil"))
    .dependsOn(scalavro_core)
    .settings(
        name := "kafkaUtil",
        libraryDependencies ++= Seq(kafkaMgrApi, logslf4jlog4j,zookeeper, httpclient, gson,fastjson,jmail),
        libraryDependencies += scalaTest % Test,


    )